package com.jbit.service.impl;

import com.jbit.dto.DmItem;
import com.jbit.dto.DmItemFloor;
import com.jbit.mapper.DmItemFloorMapper;
import com.jbit.mapper.DmItemMapper;
import com.jbit.service.DmItemFloorService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DmItemFloorServiceImpl implements DmItemFloorService {
    @Resource
    private DmItemFloorMapper dmItemFloorMapper;
    @Resource
    private DmItemMapper dmItemMapper;

    @Override
    public List<DmItemFloor> queryAllFloor() {
        List<DmItemFloor> dmItemFloorList = dmItemFloorMapper.queryAllFloor();
        int floor = 1;
        for (DmItemFloor dmItemFloor : dmItemFloorList) {
            List<DmItem> itemList = dmItemMapper.queryAllFloor(dmItemFloor.getItemTypeId());
            dmItemFloor.setFloor(floor);
            dmItemFloor.setItems(itemList);
            floor++;
        }
        return dmItemFloorList;
    }
}
